var e = require;
var t = module;
var o = exports;
var n,
    i = o,
    a =
        ((n = function (e, t) {
            return (n =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
                })(e, t);
        }),
        function (e, t) {
            function o() {
                this.constructor = e;
            }
            n(e, t), (e.prototype = null === t ? Object.create(t) : ((o.prototype = t.prototype), new o()));
        }),
    r = function (e, t, o, n) {
        var i,
            a = arguments.length,
            r = a < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, o)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(e, t, o, n);
        else
            for (var s = e.length - 1; s >= 0; s--)
                (i = e[s]) && (r = (a < 3 ? i(r) : a > 3 ? i(t, o, r) : i(t, o)) || r);
        return a > 3 && r && Object.defineProperty(t, o, r), r;
    };
Object.defineProperty(i, "__esModule", {value: !0});
var s = e("AssetsMap"),
    c = e("BundleNames"),
    l = e("Util"),
    d = e("SkinLevelData"),
    u = e("TwistSnake"),
    p = e("ShopSkinViewMediator"),
    h = cc._decorator,
    f = h.ccclass,
    _ = h.property,
    y = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.snakeTwist = null),
                (t.debrisLabel = null),
                (t.gainDebrisBtn = null),
                (t.config = null),
                (t.decoIndex = null),
                t
            );
        }
        return (
            a(t, e),
            (t.prototype.initConfig = function (e) {
                (this.config = e),
                    this.snakeTwist.init(),
                    this.setSkin(),
                    (this.decoIndex = Number(l.default.getItem("dressItemUse" + this.config.index, "-1"))),
                    -1 !== this.decoIndex && this.setDecorate(),
                    this.config.isLock
                        ? (this.gainDebrisBtn.active = !1)
                        : (this.renderDebrisInfo(),
                          this.gainDebrisBtn.on(game.EngineEventType.NodeEvent.click, this.addDebris, this));
            }),
            (t.prototype.setSkin = function () {
                this.snakeTwist.setSkin(this.config.name);
            }),
            (t.prototype.setDecorate = function () {
                this.snakeTwist.setDecorate(this.decoIndex);
            }),
            (t.prototype.renderDebrisInfo = function () {
                var e = d.SkinLevelData.instance.skinList[this.config.index];
                e.level >= e.upgrade.length - 1
                    ? (this.gainDebrisBtn.active = !1)
                    : ((this.debrisLabel.string = e.fragments + "/" + e.upgrade[e.level]),
                      (this.gainDebrisBtn.getChildByName("icon").getComponent(cc.Sprite).spriteFrame =
                          l.default.getSpriteFrame(
                              c.default.Popup,
                              s.default.PopupMap.ShopSkinView.preAssets.textures.assetsList[
                                  "fragment_icon_" + this.config.name
                              ]
                          )));
            }),
            (t.prototype.addDebris = function () {
                game.appFacade.sendNotification(p.default.SKIP_EGG);
            }),
            r([_(u.default)], t.prototype, "snakeTwist", void 0),
            r([_(cc.Label)], t.prototype, "debrisLabel", void 0),
            r([_(cc.Node)], t.prototype, "gainDebrisBtn", void 0),
            r([f], t)
        );
    })(cc.Component);
i.default = y;
